<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>left</title>
<link type="text/css" rel="stylesheet" href="${css_ctx }/main_style.css" />
<script type="text/javascript">
/*跳转菜单脚本*/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval("window.open('${ctx }/common?cmd=left&tid="+selObj.options[selObj.selectedIndex].value+"','_self')");
}	

</script>
</head>

<body class="left_bg" >
<div class="left_top">
	<form name="form2" id="form2">
		<select name="cwd" >
	    	<option>承德车务段</option>
	    </select>
	    &nbsp;
	    <select name="station" onchange="MM_jumpMenu('parent',this,1)">
	    <c:choose>
	    	<c:when test="${sessionScope.manager.urole =='3' || sessionScope.manager.urole =='4' || sessionScope.manager.urole =='5'}">
	    		<option value="${sessionScope.mtrain.tid }" >${sessionScope.mtrain.tname}</option>
	    	</c:when>
	    	<c:otherwise>
		    	<c:forEach items="${trains}" var="train" varStatus="status">
		    	  <option value="${train.tid}" <c:if test="${train.tid eq number}" >selected="selected"</c:if>>${train.tname}</option>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	    </select>
	</form>
	    
</div><!--top-->
<div class="list_nav">
<script type="text/javascript">
function showBranch(branch){
	
	var objBranch = document.getElementById(branch).style;
	var objBranchbg = document.getElementById("branch" + branch).style;  
	if (objBranch.display=="block") {
		objBranchbg.backgroundImage="url(${img_ctx }/closed.gif)";
		objBranch.display="none"; 
	} else {
		objBranchbg.backgroundImage="url(${img_ctx }/open.gif)";
		objBranch.display="block"; swapFolder(branch); 
	}
} 
function swapFolder(img){
	var objImg = document.getElementById(img); 
	objImg.src = "${img_ctx }/open.gif";
	
}
   
function tree(){
	this.branches = new Array();
	this.add = addBranch;
	this.write = writeTree;
}


function addBranch(branch){
	this.branches[this.branches.length] = branch;
}

function writeTree(){
	var treeString = '';
	var numBranches = this.branches.length;
	for (var i=0;i<numBranches;i++){
	treeString += this.branches[i].write();
	document.write(treeString);
	}
}


function branch(id, text){
	this.id = id;
	this.text = text;
	this.write = writeBranch;
	this.add = addLeaf;
	this.leaves = new Array();
}


function addLeaf(leaf){
	this.leaves[this.leaves.length] = leaf;
}

function writeBranch(){
	var branchString ='<span class="branch" title="'+this.text+'" id="branch' + this.id + '"' + 'onClick="showBranch(\'' + this.id + '\')"';
	branchString += '>' + this.text;
	branchString += '</span>';
	branchString += '<span class="leaf1" id="';
	branchString += this.id + '">';    
	var numLeaves = this.leaves.length;
	for (var j=0;j< numLeaves;j++) branchString += this.leaves[j].write();
	branchString += '</span>';
	return branchString;
}

function leaf(text, link){
	this.text = text;
	this.link = link;
	this.write = writeLeaf;
}


function writeLeaf(){
	var leafString = '<a href="' + this.link + '" target="mainFrame" title="'+this.text+'">';
	leafString += this.text;
	leafString += '</a>';
	return leafString;
}

var myTree = new tree();

var root = new branch('root','root');
myTree.add(root);

	<c:forEach items="${navlist}" var="nav1" varStatus="status1">
	  <c:if test="${nav1.rule.rlevel eq '4'}">branch${nav1.rule.rid}.add(new leaf('${nav1.rule.rname}','common?cmd=reader&rid=${nav1.rule.rid}&tid=${number}'));</c:if>
	  <c:if test="${nav1.rule.rlevel ne '4'}">
	      var branch${nav1.rule.rid}= new branch('branch${nav1.rule.rid}','${nav1.rule.rname}');
	      root.add(branch${nav1.rule.rid});
	    <c:forEach items="${nav1.ruleList}" var="nav2" varStatus="status2">
	     <c:if test="${nav2.rule.rlevel eq '4'}">branch${nav1.rule.rid}.add(new leaf('${nav2.rule.rname}','common?cmd=reader&rid=${nav2.rule.rid}&tid=${number}'));</c:if>
	     <c:if test="${nav2.rule.rlevel ne '4'}">
	      var branch2${nav2.rule.rid}= new branch('branch2${nav2.rule.rid}','${nav2.rule.rname}');
		  branch${nav1.rule.rid}.add(branch2${nav2.rule.rid});
		  <c:forEach items="${nav2.ruleList}" var="nav3" varStatus="status3">
		      <c:if test="${nav3.rule.rlevel eq '4'}">branch2${nav2.rule.rid}.add(new leaf('${nav3.rule.rname}','common?cmd=reader&rid=${nav3.rule.rid}&tid=${number}'));</c:if>
	          <c:if test="${nav3.rule.rlevel ne '4'}">
	              var branch3${nav3.rule.rid}= new branch('branch3${nav3.rule.rid}','${nav3.rule.rname}');
			      branch2${nav2.rule.rid}.add(branch3${nav3.rule.rid});
		          <c:forEach items="${nav3.rules}" var="rule">
		        	 branch3${nav3.rule.rid}.add(new leaf('${rule.rname}','common?cmd=reader&rid=${rule.rid}&tid=${number}'));
		          </c:forEach>
	          </c:if>  	 
		  </c:forEach>
	     </c:if>  
		  
	  </c:forEach>
	  </c:if>  
	</c:forEach>
	

myTree.write();
var bg = document.getElementById("branchroot").style;
bg.display='none';
showBranch("root");
</script>
</div>

<script type="text/javascript"> 
<!--
var Borderpx = 201;
  /*下面为在浏览器中写出左右两个浮动窗口显示的内容*/
document.writeln("<div id=\"kuaiguan\" >");
document.writeln("<a href=\"#\" onmousedown=\"showLeft() \"><img src=\"${img_ctx }/kuaiguan.gif\" width=\"9\" height=\"22\" /><\/a>");
document.writeln("<\/div>");
function scall(){  //scale() 方法保存当前图像状态的一份拷贝
	document.getElementById("kuaiguan").style.left=document.documentElement.scrollLeft + Borderpx;
}
function showLeft(){ 

	if(window.parent.bottom.cols == '9,* '){
		window.parent.bottom.cols= '210,* ';
		Borderpx = 201;
	} else {
		window.parent.bottom.cols= '9,* ';
		Borderpx = 0;
	}
} 
window.setInterval("scall()", 100);
//-->
</script>
</body>
</html>
